package cz.khfotbal.beans;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cz.khfotbal.domain.Delegat;
import cz.khfotbal.service.DelegatService;

@Component
@Scope(value = "session")
public class DelegatBean {

	@Autowired
	private DelegatService delegatService;

	private Delegat newDelegat = new Delegat();
	private Delegat selectedDelegat;
	private List<Delegat> filteredDelegats;

	public List<Delegat> getDelegatList() {
		return delegatService.getAllDelegats();
	}

	public void updateDelegat() {
		if (selectedDelegat != null) {
			delegatService.updateDelegat(selectedDelegat);
		}
	}

	public void createDelegat() {
		delegatService.createDelegat(newDelegat);
		newDelegat = new Delegat();
	}

	public DelegatService getDelegatService() {
		return delegatService;
	}

	public void setDelegatService(DelegatService delegatService) {
		this.delegatService = delegatService;
	}

	public Delegat getNewDelegat() {
		return newDelegat;
	}

	public void setNewDelegat(Delegat newDelegat) {
		this.newDelegat = newDelegat;
	}

	public Delegat getSelectedDelegat() {
		return selectedDelegat;
	}

	public void setSelectedDelegat(Delegat selectedDelegat) {
		this.selectedDelegat = selectedDelegat;
	}

	public List<Delegat> getFilteredDelegats() {
		return filteredDelegats;
	}

	public void setFilteredDelegats(List<Delegat> filteredDelegats) {
		this.filteredDelegats = filteredDelegats;
	}

}
